package com.yl.auth.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yl.auth.entity.HulidengjiBean;
import com.yl.auth.entity.Qingdu;
import com.yl.auth.service.HulidengjiService;
import com.yl.auth.service.QingduService;
import com.yl.auth.service.ZhongdService;
import com.yl.auth.service.ZhongduService;
import com.yl.common.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 王帅洋
 * @datetime 2023/6/20 21:16
 * @description 类对象
 */
@Api(tags = "基础设置-护理等级")
@RestController
@RequestMapping("/admin/hulidengji")
public class HulidengjiController {
    @Resource
    private HulidengjiService hulidengjiService;
    //轻度
    private QingduService qingduService;
    @Resource
    //中度
    private ZhongdService zhongdService;
    @Resource
    //重度
    private ZhongduService zhongduService;
    @ApiOperation(value = "全查护理等级+分页")
    @GetMapping("/findAll/{page}/{limit}")
    public Result<IPage> findAll(@PathVariable Integer page, @PathVariable Integer limit, HulidengjiBean hulidengjiBean){
        Page page1 = new Page(page,limit);
        QueryWrapper<HulidengjiBean> queryWrapper = new QueryWrapper<>();
        Page page2 = hulidengjiService.pagehuidengji(page1,queryWrapper);
        return Result.ok(page2);
    }
    @ApiOperation(value = "添加护理等级")
    @PostMapping("/save")
    public Result save (@RequestBody HulidengjiBean hulidengjiBean){
        hulidengjiService.save(hulidengjiBean);
        return Result.ok();
    }
    @ApiOperation(value = "根据id删除护理等级")
    @DeleteMapping("/remove/{id}")
    public Result delete (@PathVariable Long id){
        hulidengjiService.removeById(id);
        return Result.ok();
    }
    @ApiOperation(value = "根据id查询---修改回显")
    @GetMapping("/get/{id}")
    public Result get(@PathVariable Long id){
        HulidengjiBean byId = hulidengjiService.getByIdHulidengji(id);
        return Result.ok(byId);
    }
    @ApiOperation(value = "根据id修改护理等级")
    @PutMapping("/update")
    public Result update(@RequestBody HulidengjiBean hulidengjiBean){
        hulidengjiService.updateById(hulidengjiBean);
        return Result.ok();
    }
    //配置护理项目
    @ApiOperation(value = "根据id查询护理等级----配置护理项目")
    @GetMapping("/getById/{id}")
    public Result getById(@PathVariable Long id){
        HulidengjiBean byId = hulidengjiService.getById(id);
        return Result.ok(byId);
    }

//    @ApiOperation(value = "根据id查询护理等级的护理项目1")
//    @GetMapping("/getPage/{id}")
//    public Result getPage(@PathVariable Long id){
//        List<HulidengjiBean> list=hulidengjiService.getlist(id);
//        return Result.ok(list);
//    }  @ApiOperation(value = "根据id查询护理等级的护理项目2")
//    @GetMapping("/getPage2/{id}")
//    public Result getPage2(@PathVariable Long id){
//        List<HulidengjiBean> list=hulidengjiService.getlist2(id);
//        return Result.ok(list);
//    }
//    @ApiOperation(value = "根据id查询护理等级的护理项目3")
//    @GetMapping("/getPage3/{id}")
//    public Result getPage3(@PathVariable Long id){
//        List<HulidengjiBean> list=hulidengjiService.getlist3(id);
//        return Result.ok(list);
//    }
    @ApiOperation(value = "根据等级id查询等级项目----配置护理项目")
    @GetMapping("/getPageAll/{id}")
    public Result getPageAll(@PathVariable Long id){
        List<HulidengjiBean> list=hulidengjiService.getPageAll(id);
        return Result.ok(list);
    }
}
